<template>
    <div>
        <!-- 顶部滑动条区域 -->
        <div id="slider" class="mui-slider">
			<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
				<div class="mui-scroll">
					<a :class="['mui-control-item',item.id==0?'mui-active':'']" v-for="item in cates" :key="item.id">
							{{item.title}}
					</a>
				</div>
			</div>
		</div>

        <!-- 图片列表区域 -->
        <ul class="photo-list">
            <router-link v-for="item in list" :key="item.id" :to="'/home/photoinfo/'+item.id" tag="li">
                <img v-lazy="item.img_url">
                <div class="info">
                    <h3 class="info-title">{{item.title}}</h3>
                    <div class="info-body">{{item.remark}}</div>
                </div>   
            </router-link>
        </ul>
    </div>    
</template>
<script>
//1.导入mui的js文件
import mui from "../../lib/mui/js/mui.min.js";
export default {
  data() {
    return {
      cates: [
        //所有分类的列表数组
        { title: "全部", id: 0 },
        { title: "生活", id: 1 },
        { title: "美女", id: 2 },
        { title: "明星", id: 3 },
        { title: "赛车", id: 4 },
        { title: "美景", id: 5 },
        { title: "动漫", id: 6 },
        { title: "健身", id: 7 },
        { title: "电竞", id: 8 },
        { title: "动物", id: 9 }
      ],
      list: [
        //所有图片的数组
        {
          id: 1,
          title: "有气质的动漫小姐姐",
          img_url: "/src/images/photolist/dm1.jpg",
          remark:
            "有气质有气质有气质有气有气质有气质有气质有气质质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质"
        },
        {
          id: 2,
          title: "有气质的动漫小姐姐",
          img_url: "/src/images/photolist/dm2.jpg",
          remark:
            "有气质有气质有气质有气有气质有气质有气质有气质质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质"
        },
        {
          id: 3,
          title: "有气质的动漫小姐姐",
          img_url: "/src/images/photolist/dm3.jpg",
          remark:
            "有气质有气质有气质有气有气质有气质有气质有气质质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质"
        },
        {
          id: 4,
          title: "有气质的动漫小姐姐",
          img_url: "/src/images/photolist/dm4.jpg",
          remark:
            "有气质有气质有气质有气有气质有气质有气质有气质质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质"
        },
        {
          id: 5,
          title: "有气质的动漫小姐姐",
          img_url: "/src/images/photolist/dm5.jpg",
          remark:
            "有气质有气质有气质有气有气质有气质有气质有气质质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质"
        },
        {
          id: 6,
          title: "有气质的动漫小姐姐",
          img_url: "/src/images/photolist/dm6.jpg",
          remark:
            "有气质有气质有气质有气有气质有气质有气质有气质质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质"
        },
        {
          id: 7,
          title: "有气质的动漫小姐姐",
          img_url: "/src/images/photolist/dm7.jpg",
          remark:
            "有气质有气质有气质有气有气质有气质有气质有气质质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质有气质"
        }
      ]
    };
  },
  mounted() {
    //2.初始化滑动控件,在mounted中初始化，保证组件已经渲染 完毕
    mui(".mui-scroll-wrapper").scroll({
      deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
    });
  }
  // methods:{
  //     getAllCategory(){
  //         this.$http.get(.....).then(function(result){
  //             if(result.body.message===0){
  //                 this.cates=result.body.message;
  //             }
  //         })
  //     }
  // }
};
</script>
<style lang="less" scoped>
* {
  touch-action: pan-y;
}
.photo-list{
    padding: 10px;
    margin: 0;
    margin-bottom: 50px;
    li{ 
        margin-bottom: 10px;
        list-style: none;
        background-color: #999;
        text-align: center;
        position: relative;
        //box-shadow的颜色要和li中的背景颜色一致，这样懒加载时加载图像周边才不会出现框框
        &:last-child{
            margin-bottom: 0;
        }
        img{
            width: 100%;
            max-height: 284px;
            vertical-align: middle;
            box-shadow: 0 0 5px #999;
        }
        .info{
            color: white;
            position: absolute;
            bottom: 0;
            text-align: left;
            background-color: rgba(0,0,0,0.4);
            .info-title{
                font-size: 14px;
            };
            .info-body{
                font-size: 13px;
            }
        }
        img[lazy=loading] {
        // 懒加载图标
            width: 40px;
            height: 300px;
            margin: auto;
            border: none;
        }
    }
}
</style>
